set mem 500m
set more off
*Create datasets to save the results 
clear
set obs 1
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen nobs=.
gen trial=.
gen iteration=.
save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample21
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample21.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2000+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample22
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample22.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2100+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample23
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample23.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2200+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample24
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample24.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2300+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample25
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample25.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2400+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample26
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample26.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2500+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample27
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample27.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2600+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample28
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample28.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2700+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample29
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample29.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2800+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

*TRUNCREG_sample30
clear 
foreach i of num 1/100{
use "C:\TRM_simulation3\sample30.dta"
capture qui truncreg y`i' x`i' z`i' if y`i'>0, ll(0) ul(1) iterate(100) 
drop _all
matrix b=get(_b)
capture svmat b
gen nobs = e(N)
gen iteration = e(ic)
gen trial = 2900+`i'
capture append using "C:\TRM_simulation3\truncreg_result3.dta"
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace
}
sort trial
capture save "C:\TRM_simulation3\truncreg_result3.dta", replace

